# -*- coding: utf-8 -*-
"""
Created on Mon Oct  7 15:58:39 2020

@author: Erfan
"""

from __future__ import print_function, division 
from casadi import *
from Parameters import *

def thetaFun(psi,pars):
    Se=if_else(psi>=0.,1.,(1+fabs(psi*pars['alpha'])**pars['n'])**(-pars['m']) )
    theta=pars['thetaR']+(pars['thetaS']-pars['thetaR'])*Se
    return theta

def CFun(psi,pars):
    Se=if_else(psi>=0.,1.,(1+fabs(psi*pars['alpha'])**pars['n'])**(-pars['m']) )
    dSedh=pars['alpha']*pars['m']/(1-pars['m'])*Se**(1/pars['m'])*(1-Se**(1/pars['m']))**pars['m']
    C=Se*pars['Ss']+(pars['thetaS']-pars['thetaR'])*dSedh
    return C

def KFun(psi,pars):
    Se=if_else(psi>=0.,1.,(1+fabs(psi*pars['alpha'])**pars['n'])**(-pars['m']))
    K=pars['Ks']*Se**pars['neta']*(1-(1-Se**(1/pars['m']))**pars['m'])**2
    return K
  